import os
import random

# 1.1   单分支
# user_input = int(input("请输入一个数字："))
# if user_input > 10:
#     print("输入的数字大于10")
#

# 1.2   双分支
# user_input = int(input("请输入一个数字"))
# if user_input > 10:
#     print("输入的数字比10大")
# else:
#     print("输入的数字比10小")


# 1.3 多重分支
# user_input = int(input("请输入学生成绩"))
# if user_input > 60:
#     print("及格")
# elif 90 < user_input <= 100:
#     print("优秀")
# elif 70 < user_input <= 80:
#     print("良好")
# else:
#     print("不及格")


print("=========随机数=========")
# print(random.randint(1, 100))


print("=========while循环=========")

# n = 1
# my_sum = 0
# while n <= 100:
#     my_sum += n
#     n += 1
# print(my_sum)


# n = 0
# my_sum = 0
# while n <= 100:
#     if n % 2 == 0:
#         my_sum += n
#     n += 1
# print(my_sum)

print("=========猜数游戏=========")
#
# n = 0
# r_num = random.randint(1, 100)
# min = 1
# max = 100
# while True:
#     user_input_num = int(input(f"输入{min}-{max}以内的数字"))
#     print(f"key是{r_num}")
#     n += 1
#     if user_input_num > r_num:
#         max = user_input_num
#
#     elif user_input_num < r_num:
#         min = user_input_num
#
#     else:
#         print(f"猜对了,次数为{n}")
#         break


print("=========for循环=========")
# res = 0
# for n in range(1, 101):
#     res += n
# # print(res)
#
# res = 0
# # 设置步长（计数间隔）
# for n in range(0, 101, 2):
#     if n % 2 == 0:
#         res += n
# print(res)


print("========for...in循环==========")

# print不换行
print("hello ", end="")
print("world!")

i = 1
for i in range(1, 10):
    for j in range(1, i + 1):
        print(f"{i}x{j}={i * j}\t", end='')
    print("\n")
